package com.metronoteapp.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.metronoteapp.AddNoteActivity;
import com.metronoteapp.R;

public class DialogDetailNoteClient extends Dialog implements
		android.view.View.OnClickListener {
	private String TAG = DialogDetailNoteClient.class.getSimpleName();
	private String mNoteId;
	private String mFlgImp;
	private Context mContext;
	private Dialog dialog;
	private Button btnCancel;
	private Button btnEdit;
	private TextView txtTitle;
	private TextView txtDetail;

	public DialogDetailNoteClient(Context context) {
		super(context);
		mContext = context;
	}

	public void displaydialog(String _noteID, String _title, String _detail,
			String _flgImp, String _date) {
		Log.v(TAG, _noteID +"|"+ _title +"|"+ _detail +"|"+ _flgImp);
		dialog = new Dialog(mContext);
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		dialog.setContentView(R.layout.layout_view_note);
		dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
		btnCancel = (Button) dialog.findViewById(R.id.btnExitAbout);
		btnEdit = (Button) dialog.findViewById(R.id.btnEditViewNote);

		txtTitle = (TextView) dialog.findViewById(R.id.txtTitleNoiteView);
		txtDetail = (TextView) dialog.findViewById(R.id.txtDetailNoiteView);
		mNoteId = _noteID;
		mFlgImp = _flgImp;
		txtTitle.setText(_title+"("+_date+")");
		txtDetail.setText(_detail);
		btnCancel.setOnClickListener(this);
		btnEdit.setOnClickListener(this);
		dialog.show();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnExitAbout:
			dialog.dismiss();
			break;
		case R.id.btnEditViewNote:
			Intent callAddNote = new Intent(mContext, AddNoteActivity.class);
			callAddNote.putExtra("NoteId", mNoteId);
			callAddNote.putExtra("FlgImp", mFlgImp);
			mContext.startActivity(callAddNote);
			break;
		default:
			break;
		}
	}
}
